/**
 * 
 */
package com.xinpark.webapps.itemface.web.module.screen;


import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.citrus.turbine.Context;
import com.alibaba.citrus.turbine.TurbineRunData;
import com.xinpark.shared.ServiceException;
import com.xinpark.shared.service.ItemService;
import com.xinpark.shared.service.model.ItemModel;
import com.xinpark.shared.service.param.QueryItemParam;

/**
 * The screen code for the template of editing item
 * @author Jianliang Chen, 2013-02-13 19:19:00
 *
 */
public class ItemEdit {
	@Autowired  
    private ItemService itemService;

	public void execute(Context context, TurbineRunData rundata) {
		
		try{
			/*
			 * get item object
			 */
			QueryItemParam itemParam = new QueryItemParam();
			String itemId = rundata.getParameters().getString("itemId");
			
			if( itemId != null) {
				itemParam.setItemId(itemId);
				ItemModel item = itemService.getItem(itemParam);
				context.put("item", item);
			}

			/*
			 * set shop
			 */
			String shopId = rundata.getParameters().getString("shopId");
			context.put("shopId", shopId);

		} catch (ServiceException se) {
			se.printStackTrace();
		}
	}

}
